import axios from 'axios'
// import router from '@/router'
import { getItem } from './My-storage'

const request = axios.create({
  baseURL: 'http://liufusong.top:8080',
  timeOut: 5000
})

request.interceptors.request.use((config) => {
  const token = getItem('token')
  console.log(token)
  config.headers.authorization = token
  return config
}, (e) => {
  return Promise.reject(e)
})

request.interceptors.response.use((response) => {
  return response.data
}, (e) => {
  // if (e.response.status === 401) {
  //   removeItem(key)
  //   router.push('/login')
  // } else {
  //   Toast(e.response.data.message)
  // }
  return Promise.reject(e)
})
export default request
